package com.swak.frame.operatelog;


import com.google.common.collect.Lists;
import com.swak.frame.dto.Result;
import com.swak.frame.operatelog.annotation.OperateDataLog;

import java.util.List;
import java.util.Objects;

/**
 * 日志的处理服务
 */
public interface OperateLogService {

    default Result<Void> addOperationLog(OperateDataLog operateDataLog) {
        if(Objects.isNull(operateDataLog)) {
            return Result.success();
        }
        return addOperationLogs(Lists.newArrayList(operateDataLog));
    }

    /**
     * 操作日志
     * @param operateDataLogs
     * @return
     */
    Result<Void> addOperationLogs(List<OperateDataLog> operateDataLogs);


    /**
     * 操作日志是否开启，可以根据用户的角色来开启
     * 比如操作员等
     * @return
     */
    default boolean isOperateLogEnabled(){
        return true;
    }
}
